package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoInformationMass;
import com.muyu.danmo.service.IDanmoInformationMassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 社会团体中的小社团Controller
 * 
 * @author yangle
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/danmoInformationMass")
public class DanmoInformationMassController extends BaseController
{
    @Autowired
    private IDanmoInformationMassService danmoInformationMassService;

    /**
     * 查询社会团体中的小社团列表
     */
//    @RequiresPermissions("system:danmoInformationMass:list")
    @PostMapping("/list")
    public Result<List<DanmoInformationMass>> list(@RequestBody DanmoInformationMass danmoInformationMass)
    {
        List<DanmoInformationMass> list = danmoInformationMassService.selectDanmoInformationMassList(danmoInformationMass);
        return Result.success(list);
    }

    /**
     * 导出社会团体中的小社团列表
     */
//    @RequiresPermissions("system:danmoInformationMass:export")
    @Log(title = "社会团体中的小社团", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationMass danmoInformationMass)
    {
        List<DanmoInformationMass> list = danmoInformationMassService.selectDanmoInformationMassList(danmoInformationMass);
        ExcelUtil<DanmoInformationMass> util = new ExcelUtil<DanmoInformationMass>(DanmoInformationMass.class);
        util.exportExcel(response, list, "社会团体中的小社团数据");
    }

    /**
     * 获取社会团体中的小社团详细信息
     */
//    @RequiresPermissions("system:danmoInformationMass:query")
    @GetMapping(value = "/{massId}")
    public Result getInfo(@PathVariable("massId") Long massId)
    {
        return success(danmoInformationMassService.selectDanmoInformationMassByMassId(massId));
    }

    /**
     * 新增社会团体中的小社团
     */
//    @RequiresPermissions("system:danmoInformationMass:add")
    @Log(title = "社会团体中的小社团", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result add(@RequestBody DanmoInformationMass danmoInformationMass)
    {
            return   danmoInformationMassService.insertDanmoInformationMass(danmoInformationMass);

    }

    /**
     * 修改社会团体中的小社团
     */
//    @RequiresPermissions("system:danmoInformationMass:edit")
    @Log(title = "社会团体中的小社团", businessType = BusinessType.UPDATE)
    @PostMapping("/util")
    public Result edit(@RequestBody DanmoInformationMass danmoInformationMass)
    {
        return danmoInformationMassService.updateDanmoInformationMass(danmoInformationMass);
    }

    /**
     * 删除社会团体中的小社团
     */
//    @RequiresPermissions("system:danmoInformationMass:remove")
    @Log(title = "社会团体中的小社团", businessType = BusinessType.DELETE)
	@DeleteMapping("/{massIds}")
    public Result remove(@PathVariable Long[] massIds)
    {
        return danmoInformationMassService.deleteDanmoInformationMassByMassIds(massIds);
    }
}
